package com.zsc.graduate.qovipan.sql;

import com.zsc.graduate.qovipan.util.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 枫树下奶罐
 * @version 1.0.0
 * @date 2022/2/11 16:04
 */
//@SuppressWarnings("ALL")
//@Transactional
//@Service
//@Mapper
//public class UserOperations {
//
//    //根据id获取用户对象, 如果不存在返回null
//    @Select("SELECT * FROM user WHERE id=#{id}")
//    public User get(@Param("id") Long id){
//        return this.get(id);
//    }
//
//    //添加用户
//    @Insert("insert into user(id, username, password, sex, birthday, headPic, admin, regTime)" +
//            " values(#{id},#{username}, #{password}, #{sex},#{birthday}, #{headPic}, #{admin}), #{regTime}")
//    @Options(useGeneratedKeys = true, keyProperty = "id")  //返回自增主键，保存在id
//    public User insert(User user){
//        this.insert(user);
//        return this.get(user.getId());
//    }
//
////    //校验是否存在该用户,不存在则返回null,存在则返回用户
////    @Select("SELECT * FROM user as u WHERE u.username=#{username} and u.password=#{password}")
////    public List<User> listByUsernameAndPwd(@Param("username") String username, @Param("password") String password){
////
////    }
//
//    //使用@Param表示传递参数的名称
//    //删除用户
//    @Delete("DELETE * FROM user where id=#{id}")
//    public int delete(@Param("id") Long id){
//        return this.delete(id);
//    }
//
////    //查询所有用户
////    @Select("SELECT * FROM user")
////    public List<User> list(){
////
////    }
//
////    //根据用户名查询用户
////    @Select("SELECT * FROM user WHERE username=#{username}")
////    public List<User> listByUsername(String username){}
//
//    //更新用户
//    @Update("update user set password=#{password}, email=#{email}, status=#{status},role=#{role} where id=#{id}")
//    public User update(User user){
//        this.update(user);
//        return this.get(user.getId());
//    }
//}

